﻿#r "FSharp.PowerPack.dll"
#r "C:\\codeplex\\Toolkit.Csv\\Toolkit.Csv\\bin\\Debug\\Toolkit.Csv.dll"

open Microsoft.FSharp.Text.Lexing
open Toolkit.Csv
open System
open System.Reflection
open Microsoft.FSharp.Reflection

type MyType() =
    let mutable value : string = null
    let mutable num : Nullable<float> = Nullable<float>(0.0)
    let mutable dt : Nullable<DateTime> = Nullable<DateTime>(DateTime.MinValue)
    member x.FavoriteNumber with get() = num and set(v) = num <- v
    member x.date with get() = dt and set(v) = dt <- v
    member x.str with get() = value and set(v) = value <- v
    member x.foo with get() = "foo"

CsvParser.ParseTextAs<MyType>(',', "str, Favorite Number, date
                                    one, 1.0,             2-10-1991
                                    two, ,                7/4/2012 6:15 PM"
                             )

(*
#load "Parser.fs"
#load "Separator.fs"
#load "Lexer.fs"
#load "CsvParser.fs"

let csvStr = "left,right\nhello,world\nfoo,bar"
CsvParser.ParseTextAsDictionaries(',', csvStr)

let lexbuf = Lexing.LexBuffer<_>.FromString(csvStr)
let records = Parser.start Lexer.tokenize lexbuf

// Print tokens
while not lexbuf.IsPastEndOfStream do  printfn "%A" (Lexer.tokenize lexbuf)
*)